#!/bin/bash

cmd=$1

print_help(){
    echo "Usage:"
    echo "sh train.sh start / stop"
}

print_error(){
    echo "Usage Error. The Usage Below:"
    echo "sh train.sh start / stop"
}

if [ "$cmd" = "" ]; then
    print_help
    exit 1
fi

if [ "$cmd" = "help" ]; then
    print_help
elif [ "$cmd" = "start" ]; then
    nohup /home/lxin49/venv/tf+keras/bin/python train.py 2>&1 > logs/train_$(date +%Y-%m-%d_%H-%M-%S).log &
elif [ "$cmd" = "stop" ]; then
    ps -ef |grep 'python train.py' |grep -v grep |awk '{print $2}' |xargs kill -9
else
    print_error
    exit 2
fi